package main

import "fmt"

type T = struct{}

func isClosed(c chan T) bool {
	select {
	case <-c:
		return true
	default:
	}
	return false
}

func main() {
	type Book struct {
		id int
	}
	bookshelf := make(chan Book, 3)
	for i := 0; i < cap(bookshelf)*2; i++ {
		select {
		case bookshelf <- Book{id: i}:
			fmt.Println("Put the Book on the shelf.", i)
		default:
			fmt.Println("The shelf is full")
		}
	}

	for i := 0; i < cap(bookshelf)*2; i++ {
		select {
		case book := <-bookshelf:
			fmt.Println("Pick up a book from the shelf", book.id)
		default:
			fmt.Println("The shelf is blank")
		}
	}

}
